// --------------------------------------------------------------------------------------------------------------------
// <copyright file="SearchScope.cs" company="Collaboris Ltd.">
//   Copyright (c) Collaboris Ltd. All rights Reserved.
// </copyright>
// <summary>
//   Defines the ScopeType type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Collaboris.SharePoint.Moss.Search
{
    using System;
    using System.Collections.Generic;
    using System.Xml.Serialization;

    [Serializable]
    public enum ScopeType
    {
        Site,   //site collection level scope
        Shared  //Shared scope. Managed by the SSP
    }

    [Serializable]
    public class SearchScope
    {

        #region Fields
        private ScopeType _scopeType;
        private string _name;
        private string _resultsPage;
        private SearchRulesCollection _searchRules = new SearchRulesCollection();
        private bool _replace;
        private string _description;
        #endregion

        #region Contructors

        public SearchScope()
        {
        }

        public SearchScope(ScopeType scopeType, string name, string resultsPage, bool replace, string description)
        {
            this._scopeType = scopeType;
            this._name = name;
            this._resultsPage = resultsPage;
            this._replace = replace;
            this._description = description;
        }

        #endregion

        #region Properties

        [XmlAttribute]
        public ScopeType Type
        {
            get { return this._scopeType; }
            set { this._scopeType = value; }
        }

        [XmlAttribute]
        public string Name
        {
            get { return this._name; }
            set { this._name = value; }
        }

        [XmlAttribute]
        public string ResultsPage
        {
            get { return this._resultsPage; }
            set { this._resultsPage = value; }
        }

        [XmlElement("Rule")]
        public SearchRulesCollection Rules
        {
            get { return this._searchRules; }
            set { this._searchRules = value; }
        }

        /// <summary>
        /// Determines the action to take if a scope with the same name already exists
        /// True - Replaces existing scope with the new one
        /// False - Leaves the current scope and just append the news rules to it.
        /// </summary>
        [XmlAttribute]
        public bool Replace
        {
            get { return this._replace; }
            set { this._replace = value; }
        }

        [XmlAttribute]
        public string Description
        {
            get { return this._description; }
            set { this._description = value;}
        }

        #endregion
    }

    [Serializable, XmlRoot(ElementName = "SearchScopes")]
    public class SearchScopeCollection: List<SearchScope>
    {

    }
}